package com.balloon.io;

import java.sql.*;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

/**
 * This class is used for handling datasource
 */
public class ConnectionManager {

    static Connection con;
    static String url;

    /**
     * This method will be used for getting connection through datasource.
     * @return
     */
    public static Connection getConnection() {
        try {
            Context ctx = new InitialContext();
            DataSource ds = (DataSource) ctx.lookup("jdbc/local");
            try {
                con = ds.getConnection();
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
        } catch (Exception e) {
            System.out.println(e);
        }
        return con;
    }
}
